require "amadeusdsl/lookup"
module Amadeusdsl
  module Graph
 
     # Graph is a singleton object
    extend self
    
    #returns a graph in format:
    #{airport => [destination airports]}
      def build_airport_graph
        airports = Amadeusdsl::Lookup.ListAirports()
        list = {}
        
        destinationParser = Amadeusdsl::Parser::DestinationParser.new
        airports.each do
          |airport|
          airport = airport[0,3]
          list[airport] = []
          destinations = destinationParser.FromCode(airport)._execute
          destinations.each do
            |destination|
            list[airport] << destination["code"]
          end
        end
        
        return list
      end
     
    
  end
end